package domain.itf;

import java.util.Set;

import util.ContactsContainer;
import util.DAOException;
import util.VersionException;
import domain.Address;
import domain.Contact;
import domain.ContactGroup;
import domain.PhoneNumber;

public interface IDAOContact {
	
	/**
	 * Get an {@link Contact} by his id.
	 * @param id
	 * @return the contact corresponding with this id.
	 * @throws {@link DAOException}
	 */
	public Contact getById(Integer id) throws DAOException;
	
	/**
	 * Get all of member contained in this Database.
	 * @return All of member contained in this Database in the {@link ContactsContainer} object.
	 * @throws {@link DAOException}
	 */
	public ContactsContainer getAllContacts() throws DAOException;
	
	/**
	 * Add a new {@link Contact}
	 * @param id
	 * @param firstname
	 * @param lastname
	 * @param emailC
	 * @param address 
	 * @param books 
	 * @param phones 
	 * @param numSiret
	 * @return the {@link Contact} created in database
	 * @throws {@link DAOException}
	 */
	public Contact addContact(String firstname, String lastname, String emailC, Address address, 
			Set<ContactGroup> books, Set<PhoneNumber> phones, Integer numSiret) 
					throws DAOException;

	/**
	 * Add a {@link Contact} with an object.
	 * @param contact
	 * @return
	 * @throws {@link DAOException}
	 */
	public Contact addContact(Contact contact) throws DAOException;
	
	/**
	 * Update a {@link Contact}.
	 * @param id
	 * @param version
	 * @param firstname
	 * @param lastname
	 * @param emailC
	 * @param address 
	 * @param books 
	 * @param phones 
	 * @param numSiret
	 * @return the {@link Contact} updated.
	 * @throws {@link DAOException}
	 * @throws {@link VersionException}
	 */
	public Contact updateContact(int id, long version, String firstname, String lastname,
			String emailC, Address address, Set<ContactGroup> books, Set<PhoneNumber> phones, Integer numSiret) 
					 throws DAOException, VersionException;

	/**
	 * Update a {@link Contact} with an object.
	 * @param contact
	 * @return the {@link Contact} updated.
	 * @throws {@link DAOException}
	 * @throws {@link VersionException}
	 */
	public Contact updateContact(Contact contact)  throws DAOException, VersionException;

	/**
	 * Delete an {@link Contact} from the database.
	 * @param memberId
	 * 					the memberId of the {@link Contact} to delete.
	 * @return true if the delete success
	 * @throws {@link DAOException}
	 */
	public boolean deleteContact(int memberId) throws DAOException;
	
	/**
	 * Search contacts with multiple criteria.
	 * @param firstName the first name or an empty string if the research don't use this parameter.
	 * @param lastName the last name or an empty string if the research don't use this parameter.
	 * @param email the email or an empty string if the research don't use this parameter.
	 * @param isAscendant the direction of the "order by" clause.
	 * @param order The criteria of the "order by" clause.
	 * @return a {@link ContactsContainer} that contains the {@link Contact}s.
	 * @throws {@link DAOException}
	 */
	public ContactsContainer searchContactsWithMultipleCriteria(final String firstName, final String lastName, 
			final String email, final boolean isAscendant, final String order) throws DAOException;

	/**
	 * Get the contact that are at least in one group of the list.
	 * @param groups
	 * @return
	 * @throws {@link DAOException}
	 */
	public ContactsContainer getByGroups(Integer[] groups) throws DAOException;
}
